/**
 * Created by jt on 2017/5/6.
 */
import "./index.less";
import "../../../unit/common/js/bootstrap_js/jquery.min.js";
import "../../../unit/common/js/bootstrap_js/select2.min.js";
import "../../../unit/common/js/bootstrap_js/jquery.multi-select.js";
import "../../../unit/common/js/bootstrap_js/jquery.dataTables.js";
import "../../../unit/common/js/bootstrap_js/form-samples.js";
import "../../../unit/common/js/bootstrap_js/table-editable.js";
import "../../../unit/common/js/bootstrap_js/form-components.js";

jQuery(document).ready(function() {
    App.init();
    // FormComponents.init();
    var token = sessionStorage.getItem('token');
    if (token == null || token =='') {
        location.href = HOST_FRT+'/logins/login.html';
    }
    jQuery('.logOut').attr('href','../logins/login.html');
    var artclId = getArgs().id;

    jQuery.ajax({
        url: HOST_ADDR+'/cpmp/artcl/view/'+artclId,
        type: 'get',
        // data: JSON.stringify(data),
        dataType: 'json',
        contentType:"application/json",
        headers: {
            'access_token': token,'login_type':'ums'
        },
        success: function(resp){
            if (!resp.success) {
                alert(resp.msgCod+' '+resp.msgInf);
                return;
            }
            console.log(resp);

            var artclTypCod;
            if (resp.data.artclTypCod == '000001') {
                artclTypCod = '重要通知';
            } else if (resp.data.artclTypCod == '000002') {
                artclTypCod = '政策法规';
            } else if (resp.data.artclTypCod == '000003') {
                artclTypCod = '采购指南';
            } else if (resp.data.artclTypCod == '000004') {
                artclTypCod = '下载中心';
            } else if (resp.data.artclTypCod == '000005') {
                artclTypCod = '常见问题';
            }

            jQuery('.artclTtl').text(resp.data.artclTtl);
            jQuery('.artclId').text(resp.data.artclId);
            jQuery('.artclTypCod').text(artclTypCod);
            jQuery('.artclCtt').html(resp.data.artclCtt)
            var atches = resp.data.atches;
            if (atches.length > 0){
                for (var i= 0;i<atches.length;i++) {
                    jQuery('#tab_3').append('<br><a href="'+HOST_FILE+atches[i].atchUrl+'">'+atches[i].atchNam+'</a>');
                }
            }
        },
        error:function(err){
            console.log(err);
        }
    });

});